package com.zhijian.warehouse.manage.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 自定义返回code码枚举
 *
 * @Author hcg
 * @DateTime 2019年4月14日 下午4:05:57
 * @Version 1.0.1
 */
@Getter
@AllArgsConstructor
public enum ResponseEnum {

    SUCCESS(200, "调用成功", "success"),
    FAILURE(500, "操作失败，请联系系统管理员", "system error"),
    DATA_NULL(501, "数据不存在或者已被删除", "the data is not exist"),
    LOGIN_WRONG(503, "用户名或密码不正确", "the username or password is wrong"),
    USER_FREEZE(504, "此用户已停用", "the user is freeze"),
    DEVICE_EXIST(506, "设备已存在", "the device is exist"),
    PHONE_REPEAT(507, "手机号重复", "the phone is repeat"),
    NAME_REPEAT(508, "名称重复", "the name is repeat"),
    USERNAME_REPEAT(509, "用户名重复", "the username is repeat"),
    DELETE_DEPENDENT_DATA_FIRST(510, "请先删除依赖数据", "please delete the dependent data first"),
    PHONE_FORMAT_ILLEGAL(511, "手机号不合法", "the phone number format is illegal"),
    ERROR_AUTH_LOGIN(10001, "登录信息已过期，请重新登录", "the token is expire,please re login"),
    SAVE_ERROR(513, "保存失败", "ope error"),
    UPDATE_ERROR(514, "修改失败", "update error"),
    DELETE_ERROR(515, "删除失败", "delete error"),
    SELECT_ERROR(516, "查询失败", "select error"),
    SAVE_PROHIBIT(517, "禁止保存", "ope prohibit"),
    UPDATE_PROHIBIT(518, "禁止修改", "update prohibit"),
    DELETE_PROHIBIT(519, "禁止删除", "delete prohibit"),
    PARENT_DATA_NULL(520, "父级数据不存在或者已被删除", "the parent data is not exist"),
    OFFICE_GROUP_INIT_ERROR(521, "部门初始化失败", "office group init error"),
    ROLE_INIT_ERROR(522, "角色初始化失败", "role init error"),
    PHONE_ALREADY_REGISTER(523, "手机号已经注册", "phone already register"),
    SCRIPT_ERROR(524, "脚本内容为空或者脚本文件生成失败", "script content error or file path init error"),
    NULL_DEVICE_TYPE(525, "设备类型不存在或者已被删除", "device type is null"),
    DEVICE_CODE_REPEAT(526, "设备编号重复", "the device code is repeat"),
    DELETE_PARAM_DEVICE_FIRST(527,"请先删除子类型下的变量或设备","please delete the param or device first"),
    ;


    public Integer code;
    public String cn;
    public String en;

    public static ResponseEnum getByCode(Integer code) {
        ResponseEnum[] values = ResponseEnum.values();
        for (ResponseEnum anEnum : values) {
            if (anEnum.getCode().equals(code)) {
                return anEnum;
            }
        }
        return null;
    }

}
